<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .css {
            width: 100px;
            height: 30px;
            background-color: red;
            border: 1px solid green;
        }

        .box {
            width: 100px;
            height: 100px;
            background-color: pink;
        }
    </style>
</head>

<body>
    <div class="box">111</div>
</body>
<script>
    // 操作类名css
    // className来改元素样式属性
    let box = document.querySelector('.box');
    // box.className = 'css';
    // 通过classList改css
    // add 添加 
    // remove 删除
    // toggle 切换
    // box.classList.add('css');
    box.addEventListener('click', function () {
        box.classList.toggle('css');
    })
</script>

</html>